package general_task;

import java.util.Vector;

public class StateStructure {

	private Vector<Atribute> structure;
	private int instant;
	
	public StateStructure(){
		instant=0;
		structure=new Vector<Atribute>();
	}

	public void addAtribute(Atribute a){
		structure.add(a);
	}

	public int maxValueAtribute(int index[]){
		return structure.elementAt(index[0]).getMaxValue(index[1]);
	}

	public Atribute getAtribute(int index){
		return structure.elementAt(index);
	}

	public String getAtributeName(int index){
		return structure.elementAt(index).getName();
	}

	public int size(TruncatedStateStructure tss){
		int s=1;
		for(int i=0;i<tss.getSize();i++){
			s*=structure.elementAt(tss.getState()[0][i]).getMaxValue(tss.getState()[1][i]);
		}
		return s;
	}

	int getStateSize(){
		return structure.size();
	}

	public int getInstant() {
		return instant++;
	}

	public int getAtributeUpdate(int i) {
		return structure.elementAt(i).update();
	}

	public int getNumberAtributes() {
		return structure.size();
	}

	public int getSeparatingStatesAtribute(State old_state, State new_state) {
		Vector<Integer> aux=new Vector<Integer>();
		for(int i=0;i<structure.size();i++){
			if (!old_state.compareAtribute(i,new_state))
					aux.add(i);
		}
		return aux.get((int)(Math.random()*aux.size()));
	}

}
